In this section we want to describe the first steps that will make the user in his first contact with the COUNTER3 device. You also want to provide a simple example using the COUNTER3 device.
We can divide in the following sections, the proceed of the operation:
As was already explained in the description of the COUNTER3 device, You must program properly the unit application configuration. It is very important to the part of code that declares the device, Here you should indicate the hardware resources to be used to ensure proper operation. It will be the responsibility of the programmer to pick and choose the most appropriate inputs and outputs. For example with the following line of code:
;--------------------------------- ; Internal device declaration ;--------------------------------- INTDEVICE ... Asse COUNTER3 2 2.CNT02 3 2.OUT01 2.OUT02
You define a COUNTER3 device with “Axis” name where the sampling time is 2 ms. Have been declared the following hardware resources: the input to the bidirectional counter has address 2.CNT02 (2 indicates the slot where installed the card, while CNT02 is the mnemonic name of the input), the number of digital input for interruption dedicated to the acquisition of the count (number 3) and finally the addresses of two exits used by comparators.
An application that has just inside the device declaration in the configuration unit and the qcl unit that it does not run anything (with the exception of the forced WAIT) already allows to perform the first operations using the capabilities of the device. In fact after downloading the application on the instrument and have done work, it can change the parameters, observe the States or give commands to devices using the appropriate monitor from QView.
This is very convenient in the early stages of planning when you just want to make some runs or being debugged.
Once declared hardware resources properly to use you need to set some parameters as components that are connected to the product Qmove.
Let us consider the case that the bi-directional transducer is a digital encoder. Suppose that the encoder is directly keyed on an motor that is to move an axis. You will need to set the measure and pulse parameters of the device so that it can interpret the pulses arriving at QMove, the instrument will then calculate the position of the axis. The measure and pulse intrduction establishes a correspondence between a space in a unit of your choice and a certain number of pulses. In the event that the user already knows the space covered in a round encoder then you'll proceed directly to projecting values.
Let's clarify this concept with an example: If the encoder emits 1000 pulses/Rev and you know that the axis moves about 5 cm when the encoder covers exactly one revolution then you can enter the following values:
Axis:measure = 50; Axis:pulse = 4000
The measure value introduced also involves choosing a unit of measure of mm for measuring positions, in the pulse parameter introduces a value equal to the number of encoder impulses multiplied by 4. It is remember that the measure/pulse relationship must be a value between 0.00935 to 1 (for compliance with the limits of accuracy of the device and the QMove product). It is important to emphasize that the values described above are taken as reference: It is not necessary to introduce the parameters with reference to an encoder revolution as we will describe below.
When the user does not know in advance the measurement parameters, will still be able to make the correct calibration by following these steps:
The encoder resolution is now correctly set.
Nella sezione precedente è stato spiegato quali sono i primi passi da seguire. In questa sezione è inserito un codice di esempio, dettagliatamente commentato, da cui l'utilizzatore può prendere spunto per sviluppare un applicativo.
Il modo in cui il device va dichiarato è spiegato precedentemente, e perciò in questa sezione è omessa la unit di configurazione. Vedi qui
;*************************************************************************************
; Unit Qcl
;*************************************************************************************
;-------------------------------------------------------------------------------------
; Operazioni di parametrizzazione del device
; ----------------------------- variabili utilizzate --------------------------------
; slSet1: Quota di comparazione per uscita 2.OUT01
; slSet2: Quota di comparazione per uscita 2.OUT02
;-------------------------------------------------------------------------------------
Asse:measure = 1000
Asse:pulse = 1000 ;come calcolare measure e pulse è spiegato nel paragrafo apposito*.
Asse:capture = 1 ;la posizione istantanea dell'asse viene catturata sul primo fronte di
;discesa dopo l'attivazione di st_intenbl
IF slSet1 EQ 0
slSet1 = 500
ENDIF
IF slSet2 EQ 0
slSet2 = 100
ENDIF
;-------------------------------------------------------------------------------------
; Funzione di homing abilitata ad ogni passaggio sul finecorsa
; ---------------------------- variabili utilizzate ---------------------------------
; slPrsPos : posizione di home impostata
;--------------------------------------------------------------------------------------
MAIN:
IF ifAbilZ ;Attesa dell'ingresso di abilitazione impulso di zero trasduttore
INTENBL Asse ;Abilita la cattura dell'impulso di zero trasduttore
ELSE
INTDSBL Asse ;Disabilita la cattura dell'impulso di zero trasduttore
ENDIF
IF Asse:st_capture ;Se è stata catturata la posizione istantanea
IF ifAxeFermo ;Se l'asse è fermo
Asse:delta = -(Asse:delta-slPrsPos) ;Calcolo quota da sommare al conteggio
DELCNT Asse ;Imposto il nuovo valore del conteggio
RSCAPTURE Asse ;Resetto st_capture dell'Asse
ENDIF
ENDIF
;-------------------------------------------------------------------------------------
; Comparazioni sul conteggio solo se ifAbilComp attivo, altrimenti le uscite
; sono disattive
;-------------------------------------------------------------------------------------
IF ifAbilComp
IF NOT gfApp01
Asse:mode1 = 5 ;Attiva out1 se posit>setpoint1
Asse:selout1 = 0 ;e disattiva out1 se posit<setpoint1
Asse:setpoint1 = slSet1 :impostazione del setpoint comparatore 1
Asse:timer1 = 0 ;nessun ritardo nella commutazione dell'uscita
Asse:mode2 = 6 ;Disattiva out2 se posit>setpoint2
Asse:selout2 = 1 ;e attiva out2 se posit<setpoint2 comparatore 2
Asse:setpoint2 = slSet2 ; impostazione del setpoint
Asse:timer2 = 0 ;nessun ritardo nella commutazione dell'uscita
gfApp01 = 1
gfApp02 = 0
ENDIF
ELSE
IF NOT gfApp02
Asse:mode1 = 0
RESOUT out201 ;Disattiva out1
Asse:selout1 = 0
Asse:mode2 = 0
RESOUT out202 ;Disattiva out2
Asse:selout2 = 1
gfApp01 = 0
gfApp02 = 1
ENDIF
ENDIF
;-------------------------------------------------------------------------------------
; Operazioni finali
;-------------------------------------------------------------------------------------
WAIT 1
JUMP MAIN
END
*come calcolare measure e pulse è spiegato nel paragrafo apposito